#coding=utf-8
#Boa:FramePanel:PanelOverdueCustomer

import wx

from MyListCtrl import *

[wxID_PANELOVERDUECUSTOMER, wxID_PANELOVERDUECUSTOMERBUTTONREFRESH, 
 wxID_PANELOVERDUECUSTOMERCHECKBOX1, 
 wxID_PANELOVERDUECUSTOMERCHECKBOX_ONLY_DELIVERY_CUSTOMER, 
 wxID_PANELOVERDUECUSTOMERCOMBOBOXSALESMAN, 
 wxID_PANELOVERDUECUSTOMERSTATICTEXT1, 
] = [wx.NewId() for _init_ctrls in range(6)]

class PanelOverdueCustomer(wx.Panel):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Panel.__init__(self, id=wxID_PANELOVERDUECUSTOMER,
              name=u'PanelOverdueCustomer', parent=prnt, pos=wx.Point(625, 294),
              size=wx.Size(1070, 811), style=wx.TAB_TRAVERSAL)
        self.SetClientSize(wx.Size(1054, 773))
        self.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False,
              u'\u6977\u4f53_GB2312'))
        self.SetBackgroundColour(wx.Colour(183, 209, 173))

        self.comboBoxSalesman = wx.ComboBox(choices=[],
              id=wxID_PANELOVERDUECUSTOMERCOMBOBOXSALESMAN,
              name=u'comboBoxSalesman', parent=self, pos=wx.Point(130, 8),
              size=wx.Size(150, 24), style=0, value=u'')
        self.comboBoxSalesman.SetLabel(u'')
        self.comboBoxSalesman.Bind(wx.EVT_COMBOBOX,
              self.OnComboBoxSalesmanCombobox,
              id=wxID_PANELOVERDUECUSTOMERCOMBOBOXSALESMAN)

        self.staticText1 = wx.StaticText(id=wxID_PANELOVERDUECUSTOMERSTATICTEXT1,
              label=u'\u8d1f\u8d23\u4eba\uff1a', name='staticText1',
              parent=self, pos=wx.Point(16, 16), size=wx.Size(68, 16), style=0)

        self.checkBox1 = wx.CheckBox(id=wxID_PANELOVERDUECUSTOMERCHECKBOX1,
              label=u'\u663e\u793a\u672a\u8d85\u671f\u4e94\u91d1\u5e97',
              name='checkBox1', parent=self, pos=wx.Point(312, 16),
              size=wx.Size(160, 16), style=0)
        self.checkBox1.SetValue(False)
        self.checkBox1.Bind(wx.EVT_CHECKBOX, self.OnCheckBox1Checkbox,
              id=wxID_PANELOVERDUECUSTOMERCHECKBOX1)

        self.buttonRefresh = wx.Button(id=wxID_PANELOVERDUECUSTOMERBUTTONREFRESH,
              label=u'\u5237\u65b0', name=u'buttonRefresh', parent=self,
              pos=wx.Point(916, 8), size=wx.Size(93, 26), style=0)
        self.buttonRefresh.Bind(wx.EVT_BUTTON, self.OnButtonRefreshButton,
              id=wxID_PANELOVERDUECUSTOMERBUTTONREFRESH)

        self.checkBox_only_delivery_customer = wx.CheckBox(id=wxID_PANELOVERDUECUSTOMERCHECKBOX_ONLY_DELIVERY_CUSTOMER,
              label=u'\u53ea\u663e\u793a\u9001\u8d27\u8def\u7ebf\u4e0a\u7684\u5ba2\u6237',
              name=u'checkBox_only_delivery_customer', parent=self,
              pos=wx.Point(504, 16), size=wx.Size(320, 16), style=0)
        self.checkBox_only_delivery_customer.SetValue(False)

    def __init__(self, parent):
        self._init_ctrls(parent)
        
        self.lcCustomer = MyListCtrlOverdueCustomer(self)
        self.lcCustomer.Move(wx.Point(10, 40))
        self.lcCustomer.SetSize(wx.Size(1000, 650))
        self.lcCustomer.refresh()
        
        self.cbPioneer = MyComboBoxDecorator(self.comboBoxSalesman, CDataStaff, CDataStaff.COL_NAME, only_enable_staff)
        self.cbPioneer.refresh()
        
    def OnRegionItemSelected(self, event):
        item = self.lcRegion.GetNextItem(-1, state = wx.LIST_STATE_SELECTED)
        regionId = self.lcRegion.getRegionId(item)
        self.lcCustomer.refresh({
            'regionId':regionId
        })

    def OnBtnRegionButton(self, event):
        event.Skip()

    def OnBtnSearchButton(self, event):
        event.Skip()

    def OnComboBoxSalesmanCombobox(self, event):
        event.Skip()

    def OnCheckBox1Checkbox(self, event):
        event.Skip()

    def OnButtonRefreshButton(self, event):
        
        filter = {}
        pioneerObj = self.cbPioneer.getSelectObj()
        if pioneerObj is not None:
            filter['salesman'] = pioneerObj.getValue(CDataStaff.COL_ID)
            
        filter['show_all'] = self.checkBox1.GetValue()
        filter['only_show_delivery'] = self.checkBox_only_delivery_customer.GetValue()
            
        self.lcCustomer.refresh(filter)

        
